package cn.itcast.mp.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

    //插入时填充数据
    @Override
    public void insertFill(MetaObject metaObject) {
        //先获取到password的值，在进行判断 为空填充  否则不填充
        Object password = getFieldValByName("password", metaObject);
        if(null == password){
            //字段为空，可以进行填充
            setFieldValByName("password", "888888", metaObject);
        }
    }

    //更新时填充数据
    @Override
    public void updateFill(MetaObject metaObject) {

    }
}
